package com.dankegongyu.testscreenrecord;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.dankegongyu.screenrecord.DkScreenRecord;
import com.dankegongyu.screenrecord.IRecordListener;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.startRecord).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DkScreenRecord.startRecordWithImg(MainActivity.this, new IRecordListener() {
                    @Override
                    public void onAsyncStopRecordScreen(final String filePath) {
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                Toast.makeText(getApplicationContext(), "" + filePath, Toast.LENGTH_LONG).show();
                            }
                        });
                    }

                    @Override
                    public void onClick() {
                        DkScreenRecord.stopRecord(getApplicationContext());
                        Toast.makeText(getApplicationContext(), "点击", Toast.LENGTH_LONG).show();
                    }
                });
            }
        });
    }
}
